package rohyunji.swing.outline;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.ButtonGroup;
import javax.swing.JTextField;
import javax.swing.JPasswordField;
import javax.swing.JTextArea;
import javax.swing.JLabel;
import javax.swing.JCheckBox;
import javax.swing.JButton;
import javax.swing.JScrollPane;
import java.awt.Dimension;
import javax.swing.SwingConstants;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JComboBox;
import javax.swing.JTable;
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;
import java.awt.Insets;
import javax.swing.JRadioButton;
import javax.swing.DefaultComboBoxModel;
import javax.swing.BoxLayout;
import java.awt.FlowLayout;
import javax.swing.JList;

/*스윙 기본 컴포넌트 (텍스트 입력)
 * Jcomponent 클래스에서 상속받은 클래스
 * 문자 '가' 문자 '가나 다라' 텍스트 '여러줄 문자들'
 * JTextField :한줄의 문자열을 입력받음
 * JPasswordField : 입력받은 문자를 *를 치환해 출력
 * JTextArea :여러줄의 문자열을 입력받음
 */
public class J18_BasicComponent extends JFrame {

	private JPanel contentPane;
	private JTextField textField;

	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					J18_BasicComponent frame = new J18_BasicComponent();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	public J18_BasicComponent() {
		setTitle("공고등록");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 450, 800);
		setResizable(false);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS));

		JPanel panel = new JPanel();
		panel.setPreferredSize(new Dimension(10, 650));
		contentPane.add(panel);

		JPanel panel_5 = new JPanel();
		panel.add(panel_5);
		GridBagLayout gbl_panel_5 = new GridBagLayout();
		gbl_panel_5.columnWidths = new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
				0 };
		gbl_panel_5.rowHeights = new int[] { 0, 0, 0, 0, 0 };
		gbl_panel_5.columnWeights = new double[] { 0.0, 1.0, 1.0, 0.0, 0.0,
				0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE };
		gbl_panel_5.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0,
				Double.MIN_VALUE };
		panel_5.setLayout(gbl_panel_5);

		JLabel lblNewLabel = new JLabel("공고제목:");
		GridBagConstraints gbc_lblNewLabel = new GridBagConstraints();
		gbc_lblNewLabel.anchor = GridBagConstraints.EAST;
		gbc_lblNewLabel.insets = new Insets(0, 0, 5, 5);
		gbc_lblNewLabel.gridx = 0;
		gbc_lblNewLabel.gridy = 0;
		panel_5.add(lblNewLabel, gbc_lblNewLabel);
		lblNewLabel.setMaximumSize(new Dimension(40, 15));
		lblNewLabel.setHorizontalAlignment(SwingConstants.LEFT);

		textField = new JTextField();
		GridBagConstraints gbc_textField = new GridBagConstraints();
		gbc_textField.gridwidth = 8;
		gbc_textField.insets = new Insets(0, 0, 5, 5);
		gbc_textField.fill = GridBagConstraints.HORIZONTAL;
		gbc_textField.gridx = 1;
		gbc_textField.gridy = 0;
		panel_5.add(textField, gbc_textField);
		textField.setColumns(1);

		ButtonGroup radios = new ButtonGroup();

		JLabel label_4 = new JLabel("기업이름:");
		GridBagConstraints gbc_label_4 = new GridBagConstraints();
		gbc_label_4.insets = new Insets(0, 0, 5, 5);
		gbc_label_4.gridx = 0;
		gbc_label_4.gridy = 1;
		panel_5.add(label_4, gbc_label_4);

		JLabel lblNewLabel_3 = new JLabel("");
		GridBagConstraints gbc_lblNewLabel_3 = new GridBagConstraints();
		gbc_lblNewLabel_3.insets = new Insets(0, 0, 5, 5);
		gbc_lblNewLabel_3.gridx = 1;
		gbc_lblNewLabel_3.gridy = 1;
		panel_5.add(lblNewLabel_3, gbc_lblNewLabel_3);

		JLabel label_3 = new JLabel("모집학력:");
		GridBagConstraints gbc_label_3 = new GridBagConstraints();
		gbc_label_3.anchor = GridBagConstraints.EAST;
		gbc_label_3.insets = new Insets(0, 0, 5, 5);
		gbc_label_3.gridx = 0;
		gbc_label_3.gridy = 2;
		panel_5.add(label_3, gbc_label_3);

		

		final JComboBox comboBox_s = new JComboBox();

		comboBox_s.setEnabled(false);
		comboBox_s.setModel(new DefaultComboBoxModel(new String[] { "1", "2",
				"3", "4", "5", "6", "7", "8", "9", "10" }));
		GridBagConstraints gbc_comboBox = new GridBagConstraints();
		gbc_comboBox.anchor = GridBagConstraints.WEST;
		gbc_comboBox.insets = new Insets(0, 0, 0, 5);
		gbc_comboBox.gridx = 4;
		gbc_comboBox.gridy = 3;
		panel_5.add(comboBox_s, gbc_comboBox);
		
		JComboBox comboBox_3 = new JComboBox();
		comboBox_3.setPreferredSize(new Dimension(28, 21));
		comboBox_3.setModel(new DefaultComboBoxModel(new String[] { "박사", "학사",
				"대졸", "전졸", "고졸", "무관" }));
		GridBagConstraints gbc_comboBox_3 = new GridBagConstraints();
		gbc_comboBox_3.fill = GridBagConstraints.HORIZONTAL;
		gbc_comboBox_3.insets = new Insets(0, 0, 5, 5);
		gbc_comboBox_3.gridx = 1;
		gbc_comboBox_3.gridy = 2;
		panel_5.add(comboBox_3, gbc_comboBox_3);

		JLabel label_1 = new JLabel("(");
		GridBagConstraints gbc_label_1 = new GridBagConstraints();
		gbc_label_1.insets = new Insets(0, 0, 0, 5);
		gbc_label_1.anchor = GridBagConstraints.EAST;
		gbc_label_1.gridx = 3;
		gbc_label_1.gridy = 3;
		panel_5.add(label_1, gbc_label_1);

		JLabel label = new JLabel("년");
		GridBagConstraints gbc_label = new GridBagConstraints();
		gbc_label.anchor = GridBagConstraints.WEST;
		gbc_label.insets = new Insets(0, 0, 0, 5);
		gbc_label.gridx = 5;
		gbc_label.gridy = 3;
		panel_5.add(label, gbc_label);

		
		
		
		
		
		
		
		final JComboBox comboBox_b = new JComboBox();

		comboBox_b.setEnabled(false);
		comboBox_b.setModel(new DefaultComboBoxModel(
				new String[] { "이상", "미만" }));
		GridBagConstraints gbc_comboBox_b = new GridBagConstraints();
		gbc_comboBox_b.anchor = GridBagConstraints.WEST;
		gbc_comboBox_b.insets = new Insets(0, 0, 0, 5);
		gbc_comboBox_b.gridx = 6;
		gbc_comboBox_b.gridy = 3;
		panel_5.add(comboBox_b, gbc_comboBox_b);

		final JComboBox comboBox_e = new JComboBox();
		comboBox_e.setEnabled(false);
		comboBox_e.setModel(new DefaultComboBoxModel(new String[] { "2", "3",
				"4", "5", "6", "7", "8", "9", "10", "15", "20" }));
		GridBagConstraints gbc_comboBox_e = new GridBagConstraints();
		gbc_comboBox_e.anchor = GridBagConstraints.WEST;
		gbc_comboBox_e.insets = new Insets(0, 0, 0, 5);
		gbc_comboBox_e.gridx = 7;
		gbc_comboBox_e.gridy = 3;
		panel_5.add(comboBox_e, gbc_comboBox_e);

		
		comboBox_b.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				if (comboBox_b.getSelectedItem() == "미만")
					comboBox_e.setEnabled(false);
				else if (comboBox_b.getSelectedItem() == "이상")
					comboBox_e.setEnabled(true);
					int i=comboBox_s.getSelectedIndex();
					
					comboBox_e.setModel(new DefaultComboBoxModel
							(new String[] { "2", "3",
							"4", "5", "6", "7", "8", "9", "10", "15", "20" }));
			}
		});
		JLabel lblNewLabel_2 = new JLabel("년 미만");
		GridBagConstraints gbc_lblNewLabel_2 = new GridBagConstraints();
		gbc_lblNewLabel_2.anchor = GridBagConstraints.WEST;
		gbc_lblNewLabel_2.insets = new Insets(0, 0, 0, 5);
		gbc_lblNewLabel_2.gridx = 8;
		gbc_lblNewLabel_2.gridy = 3;
		panel_5.add(lblNewLabel_2, gbc_lblNewLabel_2);

		JLabel label_2 = new JLabel(")");
		GridBagConstraints gbc_label_2 = new GridBagConstraints();
		gbc_label_2.insets = new Insets(0, 0, 0, 5);
		gbc_label_2.gridx = 9;
		gbc_label_2.gridy = 3;
		panel_5.add(label_2, gbc_label_2);

		JLabel lblNewLabel_1 = new JLabel("모집경력:");
		GridBagConstraints gbc_lblNewLabel_1 = new GridBagConstraints();
		gbc_lblNewLabel_1.insets = new Insets(0, 0, 0, 5);
		gbc_lblNewLabel_1.anchor = GridBagConstraints.EAST;
		gbc_lblNewLabel_1.gridx = 0;
		gbc_lblNewLabel_1.gridy = 3;
		panel_5.add(lblNewLabel_1, gbc_lblNewLabel_1);

		final JRadioButton radio1 = new JRadioButton("신입");
		radio1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				if (radio1.isSelected())
					
				comboBox_s.setModel(new DefaultComboBoxModel(
						new String[] { "1", "2", "3", "4", "5", "6", "7", "8",
								"9", "10", "15" }));
				comboBox_s.setEnabled(false);
				comboBox_b.setModel(new DefaultComboBoxModel(new String[] {
						"이상", "미만" }));
				comboBox_b.setEnabled(false);
				comboBox_e.setModel(new DefaultComboBoxModel(new String[] {
						"2", "3", "4", "5", "6", "7", "8", "9", "10", "15",
						"20" }));
				comboBox_e.setEnabled(false);
			}
		});
		GridBagConstraints gbc_rdbtnNewRadioButton_1 = new GridBagConstraints();
		gbc_rdbtnNewRadioButton_1.anchor = GridBagConstraints.WEST;
		gbc_rdbtnNewRadioButton_1.insets = new Insets(0, 0, 0, 5);
		gbc_rdbtnNewRadioButton_1.gridx = 1;
		gbc_rdbtnNewRadioButton_1.gridy = 3;
		panel_5.add(radio1, gbc_rdbtnNewRadioButton_1);
		radios.add(radio1);
		final JRadioButton radio2 = new JRadioButton("경력");
		radio2.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				if (radio2.isSelected())
					
				comboBox_s.setEnabled(true);
				comboBox_b.setEnabled(true);

				comboBox_e.setEnabled(true);

			}
		});
		GridBagConstraints gbc_rdbtnNewRadioButton = new GridBagConstraints();
		gbc_rdbtnNewRadioButton.anchor = GridBagConstraints.WEST;
		gbc_rdbtnNewRadioButton.insets = new Insets(0, 0, 0, 5);
		gbc_rdbtnNewRadioButton.gridx = 2;
		gbc_rdbtnNewRadioButton.gridy = 3;
		panel_5.add(radio2, gbc_rdbtnNewRadioButton);
		radios.add(radio2);

		// JList <String>list = new JList();
		//
		//
		// panel.add(list);

		JScrollPane scrollPane = new JScrollPane();
		panel.add(scrollPane);
		scrollPane.setPreferredSize(new Dimension(380, 150));

		JTextArea textArea = new JTextArea();
		scrollPane.setViewportView(textArea);

		JPanel panel_4 = new JPanel();
		panel_4.setPreferredSize(new Dimension(10, 0));
		contentPane.add(panel_4);

		JPanel panel_2 = new JPanel();
		panel_4.add(panel_2);

		JButton btnNewButton = new JButton("다시작성");
		panel_2.add(btnNewButton);
		btnNewButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
			}
		});

		JButton btnSave = new JButton("저장");
		panel_2.add(btnSave);
	}

}
